import React, { useRef, useState, useEffect } from 'react';
import { connect } from 'umi';
import PopImgShow from '@/components/PopImgShow';
import TableDataBlock from '@/components/TableDataBlock';
import { collectionPage, } from '@/common/contact'
import { PageHeader } from 'antd';
import UserDetail from './components/userDetail';
const Gather = (props) => {
  const { loading, dispatch, list, } = props;
  const { id } = props
  const [maskVisible, setMaskVisible] = useState(false)
  const childRef = useRef();
  const handleCallback = () => {
    childRef.current.fetchGetData();
  };


  const searchItems = [
    // {
    //   label: '姓名',
    //   name: 'username',
    // },
    // {
    //   label: '手机',
    //   name: 'mobile',
    // },
    // {
    //   label: '创建时间',
    //   type: 'rangePicker',
    //   name: 'startTime',
    //   end: 'endTime',
    // },
  ];
  const getColumns = [
    {
      title: '商品名称',
      dataIndex: 'goodsName',
    },
    {
      title: '标题',
      dataIndex: 'title',
    },
    {
      title: '描述',
      dataIndex: 'description',
    },
    {
      title: '采集时间',
      dataIndex: 'createTime',
    },
    {
      title: '采集页面',
      dataIndex: 'informationCollectionPage',
      render: (e) => {
        return collectionPage[e]
      }
    },
    {
      type: 'handle',
      width: 200,
      dataIndex: 'id',
      render: (val, record) => [
        {
          title: '查看',
          click: () => {
            setMaskVisible({ show: true, detail: record })
          }
        },
      ],
    },
  ];
  return (
    <>
      <TableDataBlock
        cRef={childRef}
        params={{ organizationUserId: id }}
        loading={loading}
        searchItems={searchItems}
        columns={getColumns}
        rowKey={(record) => `${record.id}`}
        dispatchType="user/fetchListUserInformationCollectionForUser"
        {...list}
      ></TableDataBlock>
      <UserDetail visible={maskVisible} onClose={() => setMaskVisible(false)}></UserDetail>
    </>
  );
};

export default connect(({ user, loading }) => ({
  list: user.userInformationCollectionList,
  loading: loading.models.user,
}))(Gather);
